package com.yoomiito.app.utils;

import com.alibaba.fastjson.JSON;
import com.yoomiito.app.Constant;
import com.yoomiito.app.base.App;
import com.yoomiito.app.model.config.ConfigInfo;
import com.yoomiito.app.model.config.InviteUrlInfo;
import com.yoomiito.app.model.config.ReTaoBaoUrlConfigInfo;
import com.yoomiito.app.net.YmApi;
import com.yoomiito.app.net.YmApiServer;

import cn.droidlover.xdroidmvp.cache.SharedPref;
import cn.droidlover.xdroidmvp.net.XApi;

public class ConfigUtils {
    private static ConfigUtils mConfigUtils;

    public static ConfigUtils getInstance() {
        if (mConfigUtils == null) {
            synchronized (YmApi.class) {
                if (mConfigUtils == null) {
                    mConfigUtils = new ConfigUtils();
                }
            }
        }
        return mConfigUtils;
    }

    public String getReTaoBaoUrl(){
        ReTaoBaoUrlConfigInfo configInfo = getConfigInfo().getRe_tao_url();
        return configInfo.getValue();
    }

    public String getDownloadApkUel(){
        InviteUrlInfo inviteUrlInfo = getConfigInfo().getInvite_url();
        return inviteUrlInfo.getValue();
    }

    private ConfigInfo getConfigInfo(){
        String config = SharedPref.getInstance(App.getInstance()).getString(Constant.Config, "");
        return JSON.parseObject(config, ConfigInfo.class);
    }
}
